<template>
  <div>
    <div class="ele-page-header">
      <div class="ele-page-title">克隆设置</div>
    </div>
    <div
      class="ele-body"
      style="padding-bottom: 71px; background: var(--color-white)"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="160px"
        @keyup.enter.native="submit"
        @submit.native.prevent
      >
        <el-card shadow="never" body-style="padding: 22px 22px 0 22px;">
          <el-row>
            <el-col :lg="6" :md="12">
              <el-form-item label="线路三克隆接口:" prop="avatar_open">
                <el-radio-group v-model="form.avatar_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

                  <el-form-item label="线路二克隆接口:" prop="avatar_open_two">
                <el-radio-group v-model="form.avatar_open_two" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <!-- <el-form-item label="形象克隆标准版审核:" prop="avatar_check">
                <el-radio-group v-model="form.avatar_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->

              <el-form-item label="线路一克隆接口:" prop="avatar_high_open">
                <el-radio-group v-model="form.avatar_high_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>

                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <el-form-item
                label="线路四克隆接口:"
                prop="niwo_avatar_high_open"
              >
                <el-radio-group
                  v-model="form.niwo_avatar_high_open"
                  size="small"
                >
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <!-- <el-form-item
                label="形象克隆高级版审核:"
                prop="avatar_high_check"
              >
                <el-radio-group v-model="form.avatar_high_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->
              <el-form-item
                label="线路一合成并发数:"
                prop="one_synthesis_concurrency"
              >
                <el-input
                  size="small"
                  style="width: 80px"
                  v-model="form.one_synthesis_concurrency"
                >
                </el-input>
              </el-form-item>

             
            </el-col>

            <el-col :lg="6" :md="12">

                <el-form-item label="线路二创作接口:" prop="composite_open_two">
                <el-radio-group v-model="form.composite_open_two" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="线路三创作接口:" prop="composite_open">
                <el-radio-group v-model="form.composite_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <!-- <el-form-item label="视频标准创作审核:" prop="composite_check">
                <el-radio-group v-model="form.composite_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->
              <el-form-item label="线路一创作接口:" prop="video_open">
                <el-radio-group v-model="form.video_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <!-- <el-form-item label="视频高级创作审核:" prop="video_check">
                <el-radio-group v-model="form.video_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->

              <el-form-item
                label="入门版声音合成个数:"
                prop="composite_sound_synthesis_times"
              >
                <el-input
                  size="small"
                  style="width: 80px"
                  v-model="form.composite_sound_synthesis_times"
                >
                </el-input>
              </el-form-item>
              <el-form-item
                label="线路二合成并发数:"
                prop="two_synthesis_concurrency"
              >
                <el-input
                  size="small"
                  style="width: 80px"
                  v-model="form.two_synthesis_concurrency"
                >
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :lg="6" :md="12">
              <el-form-item label="声音克入门版接口:" prop="voice_open">
                <el-radio-group v-model="form.voice_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <!-- <el-form-item label="声音克隆标准版审核:" prop="voice_check">
                <el-radio-group v-model="form.voice_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->
              <el-form-item label="声音克隆高保真接口:" prop="voice_high_open">
                <el-radio-group v-model="form.voice_high_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <!-- <el-form-item label="声音克隆高保真审核:" prop="voice_high_check">
                <el-radio-group v-model="form.voice_high_check" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item> -->

              <el-form-item
                label="专业版声音克隆:"
                prop="xunfei_sound_clone_swich"
              >
                <el-radio-group
                  v-model="form.xunfei_sound_clone_swich"
                  size="small"
                >
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                label="线路三合成并发数:"
                prop="three_synthesis_concurrency"
              >
                <el-input
                  size="small"
                  style="width: 80px"
                  v-model="form.three_synthesis_concurrency"
                >
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :lg="6" :md="12">
              <el-form-item label="线路四创作接口:" prop="niwo_video_open">
                <el-radio-group v-model="form.niwo_video_open" size="small">
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                label="入门版声音合成接口:"
                prop="composite_sound_synthesis_switch"
              >
                <el-radio-group
                  v-model="form.composite_sound_synthesis_switch"
                  size="small"
                >
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>

              <el-form-item
                label="专业版声音合成:"
                prop="xunfei_sound_synthesis_swich"
              >
                <el-radio-group
                  v-model="form.xunfei_sound_synthesis_swich"
                  size="small"
                >
                  <el-radio-button :label="1" :value="1">开启</el-radio-button>
                  <el-radio-button :label="2" :value="2">关闭</el-radio-button>
                </el-radio-group>
              </el-form-item>
                <el-form-item
                label="线路四合成并发数:"
                prop="four_synthesis_concurrency"
              >
                <el-input
                  size="small"
                  style="width: 80px"
                  v-model="form.four_synthesis_concurrency"
                >
                </el-input>
              </el-form-item>
            </el-col>

          </el-row>

          <el-form-item>
            <el-button type="primary" :loading="loading" @click="submit">
              提交
            </el-button>
          </el-form-item>
        </el-card>
      </el-form>
    </div>
  </div>
</template>

<script>
import { query, save } from '@/api/cloneSet';
const DEFAULT_FORM = {
  avatar_open: 2,
  avatar_check: 2,

  avatar_high_open: 2,
  avatar_high_check: 2,

  voice_open: 2,
  voice_check: 2,

  voice_high_open: 2,
  voice_high_check: 2,

  video_open: 2,
  video_check: 2,

  composite_open: 2,
  composite_check: 2,

  face_open: 2,
  face_check: 2,

  avatar_high_way: 2,
  video_high_way: 2,
  voice_way: 2,
  xunfei_sound_clone_swich: 2,
  xunfei_sound_synthesis_swich: 2
};

export default {
  name: 'CloneSet',
  components: {},
  data() {
    return {
      // 表单提交状态
      loading: false,
      // 表单数据
      form: {
        ...DEFAULT_FORM
      },
      // 表单验证规则
      rules: {},
      // 表单验证信息
      validMsg: ''
    };
  },
  mounted() {
    query()
      .then((msg) => {
        if (msg != null) {
          this.form = msg;
        }
      })
      .catch((e) => {
        this.$message.error(e.message);
      });
  },
  methods: {
    /* 表单提交 */
    submit() {
      this.$refs['form'].validate((valid, obj) => {
        if (valid) {
          this.validMsg = '';
          this.loading = true;
          const data = {
            ...this.form
          };
          save(data)
            .then((msg) => {
              this.loading = false;
              this.$message.success(msg);
            })
            .catch((e) => {
              this.loading = false;
              this.$message.error(e.message);
            });
        } else {
          this.validMsg = ` 共有校验 ${Object.keys(obj).length} 项不通过`;
          return false;
        }
      });
    }
  }
};
</script>
